package com.xfhy.selectcity.data;

import android.content.Context;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

/**
 * @author : xfhy
 * Create time : 2021/2/25 10:59
 * Description :
 */

@Database(entities = {Area.class}, version = 1, exportSchema = false)
public abstract class AreaRoomDatabase extends RoomDatabase {

    public abstract AreaDao areaDao();

    private static volatile AreaRoomDatabase INSTANCE;

    static AreaRoomDatabase getDatabase(final Context context) {
        if (INSTANCE == null) {
            synchronized (AreaRoomDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.
                            databaseBuilder(context.getApplicationContext(), AreaRoomDatabase.class, "area_database")
                            .createFromAsset("new_city_225.db")
                            .build();
                }
            }
        }
        return INSTANCE;
    }

}